package cn.iocoder.yudao.module.system.util.agent;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 创建CusionInff内容
 */

@Data
public class CustomInfoBuild {

    private String name;
    private String email;
    private String phone;
    private String type;
    private String accountId;
    private String userId;
    private String crmBizId;
    private String regionId;


    public CustomInfoBuild() {}

    public CustomInfoBuild(String name, String email, String phone, String type, String accountId, String userId, String crmBizId) {
        this.name = name;
        this.email = email;
        this.phone = phone;
        this.type = type;
        this.accountId = accountId;
        this.userId = userId;
        this.crmBizId = crmBizId;
    }
    public Map<String, Object> buildNullCustomInfo() {
        Map<String, Object> customInfoMap = new HashMap<>();
        return customInfoMap;
    }
    public Map<String, Object> buildCustomInfoAndIdentity() {
        Map<String, Object> identityMap = buildIdentity();
        Map<String, Object> customInfoMap = new HashMap<>();
        customInfoMap.put("name", this.name);
        customInfoMap.put("email", this.email);
        customInfoMap.put("phone", this.phone);
        customInfoMap.put("type", this.type);
        customInfoMap.put("identity", identityMap);
        return customInfoMap;
    }
    public Map<String, Object> buildCustomInfo() {
        Map<String, Object> customInfoMap = new HashMap<>();
        customInfoMap.put("name", this.name);
        customInfoMap.put("email", this.email);
        customInfoMap.put("phone", this.phone);
        customInfoMap.put("type", this.type);
        return customInfoMap;
    }

    public Map<String, Object> buildIdentity() {
        Map<String, Object> identityMap = new HashMap<>();
        identityMap.put("accountId", this.accountId);
        identityMap.put("userId", this.userId);
        identityMap.put("crmBizId", this.crmBizId);
        return identityMap;
    }

    //构建headerMap1
    public Map<String, Object> buildHeader1(Map<String, Object> customInfoMap){
        Map<String, Object> headerMap = new HashMap<>();
        if(!customInfoMap.isEmpty()){
            headerMap.put("customInfo", customInfoMap);
        }
        return headerMap;
    };


    //构建headerMap2
    public Map<String, Object> buildHeader2(Map<String, Object> customInfoMap,String gpu){
        Map<String, Object> headerMap2 = new HashMap<>();
        headerMap2.put("regionId", this.regionId);
        if(StringUtils.isNotBlank(gpu)){
            headerMap2.put("gpu", gpu);
        }
        if(!customInfoMap.isEmpty()){
            headerMap2.put("customInfo", customInfoMap);
        }

        return headerMap2;
    }

    //构建headerMap3
    public Map<String, Object> buildHeader3(Map<String, Object> customInfoMap){
        Map<String, Object> headerMap3 = new HashMap<>();
        headerMap3.put("regionId",  this.regionId);
        headerMap3.put("platformType", "xxxxxxxxxxxxxxx");
        headerMap3.put("osBit", "xxxxxxxxxxxxxxx");
        headerMap3.put("supportXen", "xxxxxxxxxxxxxxx");
        headerMap3.put("supportXenGpuType", "xxxxxxxxxxxxxxx");
        headerMap3.put("isVirtual", "xxxxxxxxxxxxxxx");
        headerMap3.put("imageType", "xxxxxxxxxxxxxxx");
        headerMap3.put("supportKvmGpuType", "xxxxxxxxxxxxxxx");
        if(!customInfoMap.isEmpty()){
            headerMap3.put("customInfo", customInfoMap);
        }
        return headerMap3;
    }

    //构建headerMap4
    public Map<String, Object> buildHeader4(Map<String, Object> customInfoMap, String vpcId){
        Map<String, Object> headerMap4 = new HashMap<>();
        headerMap4.put("regionId", this.regionId); //非必填
        if(StringUtils.isNotBlank(vpcId)){//非必填
            headerMap4.put("vpcId", vpcId);
        }
//        if(StringUtils.isNotBlank(projectId)){//非必填
//            headerMap4.put("projectId", projectId);
//        }
        if(!customInfoMap.isEmpty()){
            headerMap4.put("customInfo", customInfoMap);
        }
        return headerMap4;
    }

}
